package me.fung.keen.app.route

import me.fung.keen.app.Visual
import me.fung.keen.common.ObjectBuilder


class Route : ObjectBuilder<Visual>() {

    private val registry = mutableMapOf<String, (List<Any>) -> me.fung.keen.app.Visual>()

    override fun registry(name: String, builder: (List<Any>) -> Visual) {
        registry[name] = builder
    }

    override fun obtainOrNull(name: String, params: List<Any>):Visual? {
        return registry[name]?.invoke(params)
    }

    operator fun String.invoke(block: (List<Any>) -> Visual) {
        registry[this] = block
    }
}

